package com.abner.springcloud.consumer.movie.controller;

import com.abner.springcloud.consumer.movie.engity.User;
import com.abner.springcloud.consumer.movie.service.UserFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class MovieController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("/getUser/{id}")
    public User getUser(@PathVariable String id){
        log.info("[{}] -- start query user information , id : [{}]",this.getClass(),id);
        User user = null;
        try {
            user = userFeignClient.getUserById(id);
        }catch (Exception e){
            log.error("[{}],query user is error , exception is : [{}]",this.getClass(),e);
        }
        return user;
    }
}
